// Copyright 2023 The titan Authors. All rights reserved.

// Project: titan
// CodeName: 泰坦
// IDE: GoLand
// Author: fucaihe@outlook.com
// File: main.go
// Date: 2023/12/18 10:57:03
// Description: 数据去重系统
// ********** 提供 RPC 接口 **********

package main

import (
	"fmt"

	"go.uber.org/zap"

	"titan/pkg/config"
	"titan/pkg/log"
	"titan/pkg/rpc"
)

func main() {
	conf := config.NewConfig()
	logger := log.NewLog(conf)

	addr := fmt.Sprintf("%s:%d", conf.GetString("http.ip"), conf.GetInt("http.port"))

	logger.Info("System is starting")

	app, cleanup, err := newApp(conf, logger)
	if err != nil {
		panic(err)
	}
	defer cleanup()

	logger.Info("Successfully started", zap.String("host", addr))

	// 启动 rpc 服务
	rpc.Run(app, "tcp", addr)
}
